﻿
    using Chain.BLL;
    using System;
    using System.Data;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public partial class WeiXinRuleList : PageBase
    {


        protected string GetMenuName(object objMenuName, object objparentMenuID)
        {
            if (objparentMenuID.ToString() != "0")
            {
                return ("----" + objMenuName);
            }
            return objMenuName.ToString();
        }

        protected string GetMenuTypeName(object objMenuType)
        {
            switch (Convert.ToInt32(objMenuType))
            {
                case 0:
                    return "菜单类型";

                case 1:
                    return "按钮类型";

                case 2:
                    return "链接类型";
            }
            return "未知类型";
        }

        private void GetSysRemind()
        {
            this.gvTextRule.DataSource = new WeiXinRule().GetListTwo("RuleNUmber !='1' and RuleNUmber !='2' and RuleNewsType='text' order by RuleID desc ").Tables[0];
            this.gvTextRule.DataBind();
            this.r_NewsRule.DataSource = new WeiXinNews().GetParent();
            this.r_NewsRule.DataBind();
            this.r_menu.DataSource = new WeiXinMenu().GetMenuAllInfo2().Tables[0];
            this.r_menu.DataBind();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                this.GetSysRemind();
                this.txtSystemDomain.Value = PubFunction.curParameter.strDoMain;
            }
        }

        protected void r_NewsRule_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
            {
                DataRowView item = (DataRowView) e.Item.DataItem;
                if ((item != null) && (int.Parse(item["NewsThisCount"].ToString()) >= 10))
                {
                    ((HtmlAnchor) e.Item.FindControl("add")).Attributes.Add("disabled", "disabled");
                }
                Repeater r_NewsDetail = (Repeater) e.Item.FindControl("r_NewsDetail");
                if (r_NewsDetail != null)
                {
                    int RuleID = Convert.ToInt32(((DataRowView) e.Item.DataItem)["RuleID"]);
                    DataTable dt = new WeiXinNews().GetList("NewsRuleID=" + RuleID).Tables[0];
                    r_NewsDetail.DataSource = dt;
                    r_NewsDetail.DataBind();
                }
            }
        }
    }


